#include <stdio.h>

int findLHS(int* nums, int numsSize)
{
    int max = 0;
    for(int i = 1;i < numsSize;i++)
    {
        int count = 2;
        if(nums[i] - nums[i - 1] == 1 || nums[i] - nums[i - 1] == -1)
        {
            for(int j = i + 1;j < numsSize;j++)
            {
                if(nums[j] - nums[j - 1] == 1 || nums[j] - nums[j - 1] == -1)
                    break;
                count++;
            } 
            max = max > count ? max : count;
        }
    }
    return max;
}

int main()
{
    int nums[] = {1,3,2,2,5,2,3,7};
    int numsSize = sizeof(nums)/sizeof(nums[0]);
    int n = findLHS(nums,numsSize);
    printf("%d\n",n);
    return 0;
}